package xyz.imeans.w.util;

import java.util.Random;

public class TelUtil {
    private TelUtil(){}

    private static final String[] PREFIX = {"13", "14", "15", "17", "18"};

    public static String create(String qh, String type) {
        Random random = new Random();
        if("2".equals(type)) {
            String prefix = PREFIX[random.nextInt(PREFIX.length)];

            StringBuilder numberBuilder = new StringBuilder(prefix);
            for (int i = 0; i < 8; i++) {
                numberBuilder.append(random.nextInt(10));
            }
            return String.format("%s%s", qh, numberBuilder);
        } else if ("1".equals(type)){
            int areaCodeMin = 10;
            int areaCodeMax = 99;
            int areaCode = areaCodeMin + random.nextInt(areaCodeMax - areaCodeMin + 1);
            StringBuilder phoneNumberBuilder = new StringBuilder();
            for (int i = 0; i < 8; i++) {
                phoneNumberBuilder.append(random.nextInt(10));
            }
            return String.format("0%02d-%s", areaCode, phoneNumberBuilder.toString());
        }
        return null;
    }

}
